package com.example.demo.controller;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

@Controller
@ComponentScan
public class testController {
    //前端：
    //入住日期  ：<input type="datetime-local" value="2019-09-28T13:00" name="checkinTime"/>
    @RequestMapping("/test")
    @ResponseBody
    public String getDateDemo(@RequestParam String checkinTime){
       System.out.println(checkinTime);
       SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
        try {
            //使用SimpleDateFormat的parse()方法生成Date
            Date date = sf.parse(checkinTime+":00");
            //打印Date
            System.out.println(date.toString());
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return "<script type='text/javascript'>alert('ok');</script>";
    }



    @RequestMapping("/user-book-add")
    public String getbookadd(){return "user-book-add";}
    @RequestMapping("/user-welcome")
    public String getwelcome(){return "user-welcome";}



    @RequestMapping("/admin-welcome1")
    public String getwelcome1(){

        return "/admin/welcome1";
    }



  /*  @RequestMapping("/admin-book")
    public String adminbook(Model model){


        model.addAttribute("uid","123456789");
        model.addAttribute("name","Jerry");
        return "/admin/admin-book";
    }*/

    @RequestMapping("/echarts1")
    public String echarts1(){return "/admin/admin-echarts1";}
    @RequestMapping("/echarts2")
    public String echarts2(){return "/admin/admin-echarts2";}
    @RequestMapping("/echarts3")
    public String echarts3(){return "/admin/admin-echarts3";}
    @RequestMapping("/admin-welcome")
    public String adminwelcome(){return "/admin/welcome";}


    @RequestMapping("/admin-book-add")
    public String getadminbookadd(){return "/admin/admin-book-add";}


}
